# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=sops
pkgver=3.8.1
pkgrel=0
pkgdesc="Simple and flexible tool for managing secrets"
url="https://github.com/getsops/sops"
license="MPL-2.0"
arch="all"
makedepends="go"
checkdepends="gpg gpg-agent"
source="https://github.com/getsops/sops/archive/v$pkgver/sops-$pkgver.tar.gz"
options="net" # for downloading Go modules

export CGO_ENABLED=0
export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -v ./cmd/sops
}

check() {
	# remove -trimpath. PGP tests tries to access a local PGP key.
	# kms and hcvault tests attempt to spawn a docker container.
	# shellcheck disable=2046
	GOFLAGS="${GOFLAGS/-trimpath/}" go test \
		-skip TestPGP \
		$(go list ./... | grep -v -e '/kms$' -e '/hcvault$')
}

package() {
	install -Dm755 sops -t "$pkgdir"/usr/bin/
}

sha512sums="
92557fdd8f8501cc2b8ac42ada9e7ef7e7b41f1573df2d052ce5d5060de3601eac5f780b7b6dbbb54a0b55a393192c2289a481052a8975b085e6e86b40900cb2  sops-3.8.1.tar.gz
"
